home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Arashi 1.1 / Game Source / Full Arashi Script < prev   
Text File  |  1993-07-08  |  10KB  |  383 lines

  1. /*
  2. **    PreScript:
  3. **
  4. **    The prescript normally resides in the Arashi resource fork as resource TEXT 2128. If
  5. **    you modify the actual game source, it is often easier to clear that resource and make
  6. **    modifications to the "Arashi Script" file. Arashi will use a file with that name, if
  7. **    it can be found in the same folder with the application.
  8. **
  9. **    The actual script for the game levels can be found after the prescript and the default
  10. **    game script can be found in TEXT resource 2129. The resource is used only if
  11. **    "Arashi Script" can not be found. (This is unlike TEXT 2128, which is always loaded.)
  12. **
  13. **    Don't remove this comment or type anything before it.
  14. */
  15.  
  16. //    The following variables are for internal use:
  17.  
  18.         DEPTH            =        120
  19.  
  20.         iLevelNumber    =    0
  21.         iLevelField        =    (iLevelNumber + 15) % 16 + 1 min 1 max 16
  22.         iLevelColor        =    ( (iLevelNumber+15) / 16) min 1 max 6 
  23.         iLevelBonus        =    100 * int((iLevelNumber+15) / 16)
  24.         iLevelStartBonus =    500 * int(iLevelNumber^1.5) - 500
  25.         iLevelNext        =    iLevelNumber + 1
  26.  
  27.         iPlayerMaxMove        =    12
  28.         iPlayerSuperZaps    =    1
  29.  
  30.         iShotSpeed        =        4
  31.         iShotPower        =        4
  32.         iShotColor[0]    =        1
  33.         iShotColor[1]    =        0
  34.         iShotColor[2]    =        6
  35.         iShotColor[3]    =        4
  36.         iShotColor[4]    =        5
  37.  
  38.         iFlipperPoints    =        150
  39.         iFlipperCount    =        3
  40.         iFlipperProb    =        700
  41.         iFlipperSpeed    =        65536
  42.         iFlipperRot        =        4
  43.         iFlipperColor    =        2
  44.  
  45.         iTank[0].points    =        100
  46.         iTank[0].count    =        0
  47.         iTank[0].prob    =        600
  48.         iTank[0].speed    =        65536
  49.         iTank[0].color    =        6
  50.  
  51.         iTank[1].points    =        100
  52.         iTank[1].count    =        0
  53.         iTank[1].prob    =        600
  54.         iTank[1].speed    =        65536
  55.         iTank[1].color    =        4
  56.  
  57.         iTank[2].points    =        100
  58.         iTank[2].count    =        0
  59.         iTank[2].prob    =        600
  60.         iTank[2].speed    =        65536
  61.         iTank[2].color    =        0
  62.  
  63.         iFusePoints        =        500
  64.         iFuseBullseye    =        750
  65.         iFuseCount        =        0
  66.         iFuseProb        =        600
  67.         iFuseWarpP        =        2
  68.         iFusePlayerPlus    =        40
  69.         iFuseColor[0]    =        0
  70.         iFuseColor[1]    =        5
  71.         iFuseColor[2]    =        1
  72.         iFuseColor[3]    =        4
  73.         iFuseColor[4]    =        2
  74.  
  75.         iPulsarPoints    =        200
  76.         iPulsarCount    =        0
  77.         iPulsarProb        =        600
  78.         iPulsarSpeed    =        32768
  79.         iPulsarRot        =        5
  80.         iPulsarColor    =        5
  81.         iPulsarTime        =        20
  82.         iPulsarPulsDepth=        DEPTH-DEPTH/5
  83.  
  84.         iSpikerPoints    =        50
  85.         iSpikerProb        =        100
  86.         iSpikerSpeed    =        65536
  87.         iSpikerStart    =        DEPTH
  88.         iSpikerTop        =        10
  89.         iSpikerPlasma    =        1
  90.         iSpikerPlSpeed    =        5*65536
  91.         iSpikerPlPoints    =        200
  92.         iSpikerSpikePoints=        1
  93.         iSpikerColor[0]    =        3
  94.         iSpikerColor[1]    =        0
  95.         iSpikerColor[2]    =        5
  96.  
  97.         iBoredomCount    =        4
  98.         iBoredProb        =        2000
  99.         iEndTimer        =        60
  100.         iAllowPracticeRestart    =        1
  101.         iAllowArcadeRestart        =        1
  102.         iShowSpikesMsg    =    0
  103.         iDoomsday = 0
  104.         
  105. // These are the variables you are supposed to access:
  106.  
  107.     Level            =    iLevelNumber
  108.     SubLevel        =    (Level+15) % 16
  109.     ColorLevel        =    (Level-1) / 16    min 0
  110.  
  111.     //    Flippers:
  112.     iFlipperProb    =    FlipperProb * 1000 min 0
  113.     iFlipperCount    =    FlipperCount min 0
  114.     iFlipperRot        =    FlipperRot min 0 max 100
  115.     iFlipperSpeed    =    FlipperSpeed * 65536 min 1000
  116.  
  117.     iTank[0].prob    =    FlipTankProb * 1000 min 0
  118.     iTank[0].count    =    FlipTankCount min 0
  119.     iTank[0].speed    =    FlipTankSpeed * 65536 min 1000
  120.  
  121.     //    Spikers:
  122.     iSpikerStart    =    SpikeStart min (DEPTH * 0.05) max DEPTH
  123.     iSpikerTop        =    SpikeTop min (DEPTH * 0.05) max DEPTH
  124.     iSpikerProb        =    (iSpikerTop < DEPTH) * SpikerProb * 100 min 0 max 200
  125.     iSpikerSpeed    =    SpikerSpeed * 65536 min 10000
  126.  
  127.     //    Fuseballs
  128.     iFuseCount        =    FuseCount
  129.     iFuseProb        =    FuseProb * 1000 min 0
  130.     iFuseWarpP        =    FuseWarpP * 10 min 0
  131.     iFusePlayerPlus    =    FusePlayerPlus * 100 min 0
  132.  
  133.     iTank[1].prob    =    FuseTankProb * 1000 min 0
  134.     iTank[1].count    =    FuseTankCount min 0
  135.     iTank[1].speed    =    FuseTankSpeed * 65536 min 1000
  136.  
  137.     //    Pulsars
  138.     iPulsarCount    =    PulsarCount
  139.     iPulsarProb        =    PulsarProb * 1000 min 0
  140.     iPulsarSpeed    =    PulsarSpeed * 65536 min 1000
  141.     iPulsarRot        =    PulsarRot min 0 max 100
  142.     iPulsarTime        =    PulsarTime
  143.  
  144.     iTank[2].prob    =    PulsarTankProb * 1000 min 0
  145.     iTank[2].count    =    PulsarTankCount min 0
  146.     iTank[2].speed    =    PulsarTankSpeed * 65536 min 1000
  147.  
  148.     //    Game difficulty:
  149.     iBoredomCount    =    BoredomCount
  150.     iBoredProb        =    BoredProb * 2000 min 0
  151.     iEndTimer        =    EndTimer * 60 min 1
  152.     iAllowPracticeRestart    =    AllowPracticeRestart - (Level > 95)
  153.     iAllowArcadeRestart    =    AllowArcadeRestart - (Level > 95)
  154.     iShowSpikesMsg    =    (Level > 3) - (Level > 8)
  155.     iDoomsday = (Level > 96)
  156. //    End of prescript.
  157.  
  158.  
  159. /*
  160.     Copyright:
  161.     
  162.         Arashi 1.1
  163.         Copyright ©1993, Project STORM Team
  164.  
  165.         This file is freely distributable,
  166.         but the parser and compiler for
  167.         it may only be used along with the
  168.         Arashi game. For permission to use
  169.         the compiler or parts of it for other
  170.         things, please request permission from
  171.  
  172.                         Juri Munkki
  173.             internet:    jmunkki@hut.fi
  174.             applelink:    sf0010
  175. */
  176.  
  177. FileScript=1    //    Reading from a file. (In case you are interested.)
  178.  
  179. level 1        //    Starting from level 1, use the following rules:
  180.  
  181.     AllowPracticeRestart    =    Level % 2
  182.     AllowArcadeRestart    =    Level % 2
  183.  
  184.     FlipperProb        =    1 + SubLevel / 15
  185.     FlipperCount    =    4 + SubLevel / 3 + Level / 8 - PulsarCount / 3 max 16
  186.     FlipperRot        =    (4 + Level/1.5) ^ 0.7 max 12
  187.     FlipperSpeed    =     (1.0 + Level / 12) ^ 0.3
  188.  
  189.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 3)
  190.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  191.     SpikeTop        =    DEPTH * 0.1
  192.     SpikerSpeed        =    1 + Level / 40 max 2.5
  193.     
  194.     EndTimer        =    3.2 / Level max 1.5
  195.     BoredomCount    =    2 + Level / 10 max 7
  196.     BoredProb        =    1.0 + Level / 32
  197.  
  198.     FlipTankCount    =    (SubLevel - 1) ^ 0.7 - FuseTankCount / 2
  199.     FlipTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  200.     FlipTankProb    =    0.3 + SubLevel / 20
  201.     
  202. level 11
  203.     FuseCount        =    2
  204.     FuseProb        =    0.5 + SubLevel / 15
  205.     FuseWarpP        =    Level / 100 max 0.5
  206.     FusePlayerPlus    =    Level / 40 max 0.9
  207.     
  208. level 16
  209.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  210.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 1)
  211.     
  212. level 17
  213.     FuseCount        =    0
  214.     PulsarProb        =    0.7 + SubLevel / 20
  215.     PulsarCount        =    4 + SubLevel / 5 + Level / 10 max 12
  216.     PulsarRot        =    (4 + Level/2) ^ 0.6 max 11
  217.     PulsarSpeed        =    (Level / 20) ^ 0.3
  218.     PulsarTime        =    20 - Level / 20 min 5
  219.  
  220. level 19
  221.     FuseCount        =    (Level / 3) ^ 0.7 max 6
  222.     AllowArcadeRestart    =    (Level % 2) < 1
  223.  
  224. level 30
  225.     AllowArcadeRestart    =    (Level % 2)
  226.     
  227. level 33
  228.     FuseTankCount    =    SubLevel ^ 0.3 + 2 - PulsarTankCount / 2
  229.     FuseTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  230.     FuseTankProb    =    0.3 + SubLevel / 20
  231.  
  232. level 35
  233.     AllowArcadeRestart    =    (Level % 4) < 1
  234.     
  235. level 40
  236.     PulsarTankCount    =    SubLevel ^ 0.3 + 2
  237.     PulsarTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  238.     PulsarTankProb    =    0.3 + SubLevel / 20
  239.  
  240. level 47
  241.     AllowArcadeRestart    =    (Level % 2)
  242.  
  243. level 51
  244.     AllowArcadeRestart    =    (Level % 4) < 1
  245.     
  246. level 63
  247.     AllowArcadeRestart    =    (Level % 2)
  248.     
  249. level 67
  250.     AllowArcadeRestart    =    ((Level-65) % 8) < 1
  251.     
  252. level 82
  253.     AllowArcadeRestart    =    0
  254.     
  255.     
  256. level 32000    //    We should never need to go past this point
  257.  
  258. /* Finally, some instructions on how to modify this file:
  259.  
  260.  
  261. Here's a short grammar of the language. It should be pretty obvious for anyone
  262. with a little background in grammars.
  263.  
  264. Items in braces can be repeated 
  265.  
  266. statement    ->    level n
  267.                 variable = compare
  268.  
  269. compare        ->    minmax { = minmax }
  270.                 minmax { > minmax }
  271.                 minmax { < minmax }
  272.  
  273. minmax        ->    expr { min expr }
  274.                 expr { max expr }
  275.  
  276. expr        ->    term { + term }
  277.                 term { - term }
  278.  
  279. term        ->    power { * power }
  280.                 power { / power }
  281.                 power { % power }
  282.  
  283. power        ->    factor { ^ factor }
  284.  
  285. factor        ->    (compare)
  286.                 -factor
  287.                 factor
  288.                 +factor
  289.                 variable
  290.                 constant
  291.                 function1 factor
  292.                 function0
  293.  
  294.  
  295. functions with no parameters: (function0)
  296.  
  297.         random
  298.  
  299. functions with one parameter: (function1)
  300.  
  301.         |         (abs)
  302.         sin
  303.         cos
  304.         int
  305.         round
  306.  
  307. keywords:
  308.         level
  309.  
  310.  
  311.     *********************
  312.     *    How it works    *
  313.     *********************
  314.  
  315. The idea is that you define variables and that new lines in
  316. the script will replace old lines. For a certain level, only
  317. those definitions that appear before the next greater 'level'
  318. statement will be used to define that level.
  319.  
  320. Order of evaluation is unspecified and there are no guarantees
  321. that variables will have reasonable values unless they are
  322. initialized. If a circular reference is encountered, an old
  323. value of a looped variable will be used to get out of the loop.
  324.  
  325. For instance:
  326.  
  327.     a = b
  328.     b = a + 1
  329.     
  330. If we evaluate a, we usually get 1 on the first round. This is
  331. because most variables are initialized to 0. If we execute it
  332. again, we get 2 etc. If, instead we evaluate b, we get 1, but
  333. the value of a will be 0. I hope this is confusing enough so
  334. that you will avoid circular references. Let's just say that
  335. they are not very useful, but they do not cause problems.
  336.  
  337. The order of evaluation is on a "need to know basis". I guess
  338. it's called intelligent recalculation in spreadsheet programs.
  339. Let's look at it with a short example:
  340.  
  341.     a = 10
  342.     b = a + 20
  343.     c = 30
  344.     d = b + a
  345.     
  346. If we then evaluate d, the system will try to evaluate b, notice
  347. that b requires a to be defined, so it evaluates a and then b. It
  348. then sees a again, but notices that it has been evaluated already
  349. and uses the old value. c does not get evaluated at all.
  350.  
  351. Let's look at something more complicated:
  352.  
  353.     level 1
  354.     
  355.         b = a
  356.         a = 1
  357.         a = 2
  358.  
  359.     level 16
  360.     
  361.         a = 3
  362.  
  363. From levels 1 to 15, b will evaluate to 2, because that's the last
  364. definition of a. From level 16, the value of b will be 3.
  365.  
  366. The definition a = 1 is not used at all, although it does get compiled
  367. before the next line replaces it.
  368.  
  369. To actually define a game level, you have to define variables that of
  370. interest to the game. These variables are introduced in a prescript
  371. resource. Feel free to peek at that resource to see what variables are
  372. available [during development, the prescript might be empty and the
  373. Arashi Script file could contain everything].
  374.  
  375. Variables that are prefixed with an 'i' are by convention internal
  376. variables. In the next part of the prescript, these variables are
  377. connected with variables that you should use. For instance, we have
  378. iFlipperCount and FlipperCount. You should use FlipperCount even though
  379. iFlipperCount is really the variable that the game wants. This convention
  380. allows us to scale or limit the values that can be set. For instance,
  381. we should probably limit FlipperCount to a minimum of 0.
  382.  
  383. */